﻿@model Mango.Web.Models.CartDto

@if (TempData["Error"] != null)
{
    <div class="alert alert-warning" role="alert">@TempData["Error"]</div>
}


@if (Model != null && Model.CartDetails.Count() > 0)
{
    <form method="post">

        <input asp-for="CartHeader.CartHeaderId" hidden>
        <input asp-for="CartHeader.UserId" hidden>
        <input asp-for="CartHeader.CouponCode" hidden>
        <input asp-for="CartHeader.DiscountTotal" hidden>
        <input asp-for="CartHeader.OrderTotal" hidden>

        <div>
            <span style="font-size:25px;" class="text-warning">Введите детали заказа и разместите заказ :</span>
            <br />
        </div>
        <div class="border mt-2">
            <div class="container row">
                <div class="col-7">
                    <div class="row">
                        <div class="col-12">
                            <label class="col-form-label">Имя :</label>
                            <input asp-for="CartHeader.FirstName" class="form-control" />
                        </div>
                        <div class="col-12">
                            <label class="col-form-label">Фамилия :</label>
                            <input asp-for="CartHeader.LastName" class="form-control" />
                        </div>
                        <div class="col-12">
                            <label class="col-form-label">Email :</label>
                            <input asp-for="CartHeader.Email" class="form-control" />
                        </div>
                        <div class="col-12">
                            <label class="col-form-label">Телефон :</label>
                            <input asp-for="CartHeader.Phone" class="form-control" />
                        </div>
                        <div class="col-12">
                            <label class="col-form-label">Время доставки</label>
                            <input asp-for="CartHeader.PickupDateTime" class="form-control form_datetime" type="text">
                        </div>
                        <div class="col-12">
                            <label class="col-form-label">Номер карты :</label>
                            <input asp-for="CartHeader.CardNumber" class="form-control" />
                        </div>

                        <div class="col-12">
                            <label class="col-form-label">CVV :</label>
                            <input asp-for="CartHeader.CVV" class="form-control" />
                        </div>

                        <div class="col-12 pb-4">
                            <label class="col-form-label">Карта действует до :</label>
                            <input asp-for="CartHeader.ExpiryMonthYear" placeholder="MMYY" class="form-control" />
                        </div>
                    </div>
                </div>
                <div class="col-5">
                    <div class="card mt-4">
                        <div class="card-body">
                            <div class=" d-none d-lg-block">
                                <div class="row text-danger">
                                    <div class="col-6">
                                        Продукты
                                    </div>

                                    <div class="col-3">
                                        Price
                                    </div>
                                    <div class="col-3">
                                        Count
                                    </div>
                                </div>
                            </div>

                            <hr />

                            @foreach (var cartObj in Model.CartDetails)
                            {
                                <div class="row h-100">
                                    <div class="col-6">
                                        <span style="font-size:20px">@cartObj.Product.Name</span>
                                    </div>

                                    <div class="col-3" style="font-size:11px;">
                                        <span style="font-size:17px;">  @string.Format("{0:c}", cartObj.Product.Price)</span>

                                    </div>
                                    <div class="col-3" style="font-size:11px;">
                                        <span style="font-size:17px;"> @cartObj.Count</span>
                                    </div>
                                </div>
                                <hr />
                            }

                            <div class="row">
                                <div class="col-12 text-right pr-4 text-danger">
                                    Сумма :  @string.Format("{0:c}", Model.CartHeader.OrderTotal) <br />
                                    @if (Model.CartHeader.DiscountTotal > 0)
                                    {
                                        <span class="text-success"> Скидка: @string.Format("{0:c}", Model.CartHeader.DiscountTotal)</span>
                                    }
                                </div>
                            </div>
                        </div>
                        <div class="card-footer">
                            <div class="row">

                                <div class="col-12 ">
                                    <button type="submit" class="btn btn-success form-control ">
                                        <span>Разместить заказ</span>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
}

@section Scripts {
    <script type="text/javascript">
        $(document).ready(function(){
            $(".form_datetime").datetimepicker({ format: 'dd-mm-yyyy hh:ii'});
            $('.form_datetime').datetimepicker('setStartDate', new Date());
        });
    </script>
}